package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.common.ResponseEntity;
import com.s3.khospitalds.entity.Staffintroduction;
import com.s3.khospitalds.service.EmployeeintroductionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hlq
 * @version 1.0
 * @Description
 * @date 2025/2/20 10:32
 */
@RestController
@CrossOrigin(origins = "*")
public class EmployeeintroductionController {
    @Autowired
    EmployeeintroductionService employeeintroductionService;

    //查询全部医生和护士员工
    @RequestMapping("/getIntroduce")
    public R IntroduceAll(String profession) {
        System.out.println("profession = " + profession);
        return new R().addData("douction", employeeintroductionService.IntroduceAll(profession)).addData("nurse", employeeintroductionService.NurseAll(profession));
    }

    /*
     *医生
     */
    //模糊查询科室、查询医师、查询专长
    @RequestMapping("/selectByProfession")
    public ResponseEntity selectByProfession(Integer pageNum, Integer pageSize,
                                             @Param("department") String department,
                                             @Param("special") String special,
                                             @Param("position") String position) {
        pageNum = pageNum == null ? 1 : pageNum;
        pageSize = pageSize == null ? 10 : pageSize;
        department = department == null ? "" : department;
        special = special == null ? "" : special;
        position = position == null ? "" : position;
        System.out.println("department = " + department);
        return employeeintroductionService.selectByProfession(pageNum, pageSize, department, special, position);
    }


    /*
     * 护士
     */
    @RequestMapping("/selNurse")
    public ResponseEntity selNurse(Integer pageNum, Integer pageSize,
                                             @Param("department") String department,
                                             @Param("name") String name,
                                             @Param("area") String area) {
        pageNum = pageNum == null ? 1 : pageNum;
        pageSize = pageSize == null ? 10 : pageSize;
        department = department == null ? "" : department;
        name = name == null ? "" : name;
        area = area == null ? "" : area;

        return employeeintroductionService.selNurse(pageNum, pageSize, department, name, area);
    }

}
